package com.example.dllo.my36kr.message.enter;

import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.ImageButton;

import com.example.dllo.my36kr.R;
import com.example.dllo.my36kr.tools.BaseAty;

import java.util.ArrayList;

/**
 * Created by dllo on 16/8/26.
 */
public class EnterAty extends BaseAty implements View.OnClickListener {

    private EnterAdapter adapter;
    private TabLayout tabLayout;
    private ViewPager viewPager;

    @Override
    protected int setLayout() {
        return R.layout.aty_enter;
    }

    @Override
    protected void initView() {
        adapter = new EnterAdapter(getSupportFragmentManager());
        tabLayout = bindView(R.id.register_tablayout);
        viewPager = bindView(R.id.register_vp);
        ImageButton clearIb = bindView(R.id.tb_enter_clear);
        clearIb.setOnClickListener(this);

    }

    @Override
    protected void initData() {

        ArrayList<Fragment>fragments = new ArrayList<>();
        fragments.add(new EnterFragment());
        fragments.add(new RegisterFragment());
        adapter.setFragments(fragments);
        viewPager.setAdapter(adapter);
        tabLayout.setupWithViewPager(viewPager);


    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tb_enter_clear:
                finish();
                break;
        }
    }
}
